home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 16 / PC Actual CD 16.iso / autocad / R14701.DXR / 00007_stdButtonClass.ls < prev    next >
Encoding:
Text File  |  1997-04-24  |  2.2 KB  |  77 lines

  1. property ancestor, pFunction, pFirstMemberNum, pSpriteNum, pClickedFlag, pActiveOnDownFlag, pRepeatWhileDownFlag, pRepeatDelayTicks, pForceRollFlag
  2.  
  3. on new me, myPropList
  4.   set pSpriteNum to getaProp(myPropList, #sprite)
  5.   set pFirstMemberNum to getaProp(myPropList, #firstMember)
  6.   set pFunction to getaProp(myPropList, #command)
  7.   set pClickedFlag to 0
  8.   set pDownFlag to 0
  9.   set pRepeatWhileDownFlag to getaProp(myPropList, #repeat)
  10.   set pActiveOnDownFlag to getaProp(myPropList, #down)
  11.   set pRepeatDelayTicks to getaProp(myPropList, #delay)
  12.   set pForceRollFlag to getaProp(myPropList, #forceRoll)
  13.   set ancestor to new(script "ButtonAncestor", me)
  14.   set the memberNum of sprite pSpriteNum to pFirstMemberNum
  15.   add(the actorList, me)
  16.   return me
  17. end
  18.  
  19. on mButtonDown me, myCommandArgs
  20.   if not voidp(myCommandArgs) then
  21.     set tOldFunction to pFunction
  22.     if the last char in pFunction = ")" then
  23.       if char the number of chars in pFunction - 1 of pFunction = "(" then
  24.         delete char -30000 of pFunction
  25.       else
  26.         delete char -30000 of pFunction
  27.         put "," after pFunction
  28.       end if
  29.     else
  30.       put "(" after pFunction
  31.     end if
  32.     put myCommandArgs after pFunction
  33.     put ")" after pFunction
  34.   end if
  35.   set tClickTicks to the ticks
  36.   set the memberNum of sprite pSpriteNum to pFirstMemberNum + 2
  37.   set pClickedFlag to 1
  38.   if pActiveOnDownFlag = 1 then
  39.     do(pFunction)
  40.   end if
  41.   updateStage()
  42.   repeat while the mouseDown
  43.     if rollOver(pSpriteNum) or (pForceRollFlag = 1) then
  44.       set the memberNum of sprite pSpriteNum to pFirstMemberNum + 2
  45.       set pClickedFlag to 1
  46.       repeat while (the ticks < (tClickTicks + pRepeatDelayTicks)) and the stillDown
  47.         nothing()
  48.       end repeat
  49.       if (pRepeatWhileDownFlag = 1) and the stillDown then
  50.         do(pFunction)
  51.       end if
  52.     else
  53.       set the memberNum of sprite pSpriteNum to pFirstMemberNum
  54.       set pClickedFlag to 0
  55.     end if
  56.     updateStage()
  57.   end repeat
  58.   if not voidp(tOldFunction) then
  59.     set pFunction to tOldFunction
  60.   end if
  61. end
  62.  
  63. on mButtonUp me
  64.   if not pClickedFlag then
  65.     exit
  66.   end if
  67.   if rollOver(pSpriteNum) then
  68.     if pActiveOnDownFlag = 1 then
  69.       nothing()
  70.     else
  71.       do(pFunction)
  72.     end if
  73.   end if
  74.   mResetButton(me)
  75.   set pClickedFlag to 0
  76. end
  77.